import { sysUserApi } from '@/api'
import type { WorkOrderUser } from '@/types'

/**
 * @mixin 查询处理人列表
 */
export function useUserLists() {
  const [userLists, setUserLists] = useShallowState<
    WorkOrderUser[]
  >([])

  async function getUserLists() {
    try {
      const { data }
        = await sysUserApi.queryListByTenantId()

      setUserLists(
        data?.map(v => ({
          userId: v.id,
          loginName: v.loginName,
          userName: v.userName,
        })) ?? [],
      )
    }
    catch (e) {}
  }

  return {
    userLists,
    setUserLists,
    getUserLists,
  }
}
